﻿using Dapper;
using Microsoft.AspNetCore.Mvc;
using MySql.Data.MySqlClient;
using System.Collections.Generic;
using System.Linq;
using Web.WangLuo2.Connection.MySQL.Models;
using Web.WangLuo2.Connection.MySQL.Models.DB;
//using是要拿来使用的工具

namespace Web.WangLuo2.Connection.MySQL.DAL//DAL控制器的命名空间
{
    public class DAL_Teacher : Controller//子类继承父类，冒号前为子类，反之则为父类
    {
        public List<teacher> getTeacher()//引用一个list名为teacher的列表，getteacher的方法
        {
            MySqlConnection mySqlConnection = new MySqlConnection(ConfigHelper.Configuration["MySQLConnectionString"]);//引用数据库
            var list = mySqlConnection.Query<teacher>("select  *  from teacher  ").ToList();//定义list，把数据库语句返还给list
            return list;//返回list
        }
        public List<teacher_course> getTeacher_course()//引用一个list名为teacher_course的列表，getteacher_course的方法
        {
            MySqlConnection mySqlConnection = new MySqlConnection(ConfigHelper.Configuration["MySQLConnectionString"]);//引用数据库
            var list = mySqlConnection.Query<teacher_course>("select  *  from teacher join course on teacher.TId=course.TId ").ToList();//定义list，把数据库语句返还给list
            return list;//返回list
        }
    }
}
